country_decisions = {

	moroccan_nation = {
		major = yes
		potential = {
			normal_or_historical_nations = yes
			OR = {
				ai = no
				is_playing_custom_nation = no
			}
			NOT = { tag = MOR }
			NOT = { tag = TUN }
			NOT = { tag = TLC }
			NOT = { tag = ALG }
			NOT = { tag = PAP }
			NOT = { tag = HLR }
			OR = {
				primary_culture = moroccan
				AND = {
					primary_culture = berber
					capital_scope = { area = northern_morocco_area }
				}
				AND = {
					primary_culture = berber
					capital_scope = { area = fez_area }
				}
				AND = {
					primary_culture = berber
					capital_scope = { area = marrekesh_area }
				}
				AND = {
					primary_culture = berber
					capital_scope = { area = sus_area }
				}
				AND = {
					primary_culture = berber
					capital_scope = { area = tafilalt_area }
				}
			}
			OR = {
				ai = no
				AND = {
					ai = yes
					num_of_cities = 5	#Any big Moroccan tag will try to usurp the title
				}
			}
			is_colonial_nation = no
			OR = {
				is_former_colonial_nation = no
				AND = {
					is_former_colonial_nation = yes
					ai = no
				}
			}
		}
		allow = {
			NOT = { exists = MOR }
			is_at_war = no
			is_subject = no
			is_nomad = no
			owns_core_province = 343 #Fez
			owns_core_province = 344 #Marrekech
			OR = {
				owns_core_province = 348 #Sus
				owns_core_province = 346 #Tafilalt
			}
		}
		effect = {
			change_tag = MOR
			if = {
				limit = {
					is_part_of_hre = yes
					NOT = { has_country_modifier = european_union }
					is_elector = no
				}
				every_owned_province = {
					limit = {
						is_part_of_hre = yes
					}
					set_in_empire = no
				}
			}
			if = {
				limit = {
					NOT = { government_rank = 2 }
				}
				set_government_rank = 2
			}
			tafilalt_area = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = MOR
			}
			sus_area = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = MOR
			}
			marrekesh_area = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = MOR
			}
			fez_area = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = MOR
			}
			northern_morocco_area = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = MOR
			}
			add_prestige = 25
			set_capital = 344 #Marrekech
			change_government = despotic_monarchy #Desert tribes settling down, theocracies become monarchies.
			change_primary_culture = moroccan
			country_event = { id = ideagroups.1 } #Swap Ideas
		}
		ai_will_do = {
			factor = 1
		}
		ai_importance = 400
	}
	
	algiers_nation = {
		major = yes
		potential = {
			normal_or_historical_nations = yes
			OR = {
				ai = no
				is_playing_custom_nation = no
			}
			NOT = { tag = MOR }
			NOT = { tag = TUN }
			NOT = { tag = TLC }
			NOT = { tag = ALG }
			NOT = { tag = PAP }
			NOT = { tag = HLR }
			OR = {
				primary_culture = algerian
				AND = {
					primary_culture = berber
					capital_scope = { area = algiers_area }
				}
				AND = {
					primary_culture = berber
					capital_scope = { area = kabylia_area }
				}
				AND = {
					primary_culture = berber
					capital_scope = { area = north_saharan_area }
				}
			}
			OR = {
				ai = no
				AND = {
					NOT = { exists = ALG }
					ai = yes
					num_of_cities = 5
				}
			}
			is_colonial_nation = no
			OR = {
				is_former_colonial_nation = no
				AND = {
					is_former_colonial_nation = yes
					ai = no
				}
			}
		}
		allow = {
			NOT = { exists = ALG }
			is_at_war = no
			is_subject = no
			is_nomad = no
			owns_core_province = 338 #Algiers
			owns_core_province = 2576 #Dahra
			OR = {
				owns_core_province = 336 #Tlemcen
				owns_core_province = 339 #Kabylia
			}
		}
		effect = {
			change_tag = ALG
			if = {
				limit = {
					is_part_of_hre = yes
					NOT = { has_country_modifier = european_union }
					is_elector = no
				}
				every_owned_province = {
					limit = {
						is_part_of_hre = yes
					}
					set_in_empire = no
				}
			}
			if = {
				limit = {
					NOT = { government_rank = 2 }
				}
				set_government_rank = 2
			}
			change_primary_culture = algerian
			algiers_area = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = ALG
			}
			north_saharan_area = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = ALG
			}
			kabylia_area = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = ALG
			}
			if = {
				limit = {
					is_tribal = yes	#Desert tribes settling down.
				}
				change_government = despotic_monarchy
			}
			add_prestige = 25
			set_capital = 338 #Algiers
			country_event = { id = ideagroups.1 } #Swap Ideas
		}
		ai_will_do = {
			factor = 1
		}
		ai_importance = 400
	}
	
	tunisian_nation = {
		major = yes
		potential = {
			normal_or_historical_nations = yes
			OR = {
				ai = no
				is_playing_custom_nation = no
			}
			NOT = { tag = MOR }
			NOT = { tag = TUN }
			NOT = { tag = TLC }
			NOT = { tag = ALG }
			NOT = { tag = PAP }
			NOT = { tag = HLR }
			OR = {
				primary_culture = tunisian
				AND = {
					primary_culture = berber
					capital_scope = { area = tunisia_area }
				}
				AND = {
					primary_culture = berber
					capital_scope = { area = fezzan_area }
				}
				AND = {
					primary_culture = berber
					capital_scope = { area = tripolitania_area }
				}
			}
			OR = {
				ai = no
				AND = {
					NOT = { exists = TUN }
					ai = yes
					num_of_cities = 5
				}
			}
			is_colonial_nation = no
			OR = {
				is_former_colonial_nation = no
				AND = {
					is_former_colonial_nation = yes
					ai = no
				}
			}
		}
		allow = {
			NOT = { exists = TUN }
			is_at_war = no
			is_subject = no
			is_nomad = no
			owns_core_province = 341 #Tunis
			owns_core_province = 2584 #Souss
			OR = {
				owns_core_province = 2583 #Kef
				owns_core_province = 354 #Tripoli
			}
		}
		effect = {
			change_tag = TUN
			if = {
				limit = {
					is_part_of_hre = yes
					NOT = { has_country_modifier = european_union }
					is_elector = no
				}
				every_owned_province = {
					limit = {
						is_part_of_hre = yes
					}
					set_in_empire = no
				}
			}
			if = {
				limit = {
					NOT = { government_rank = 2 }
				}
				set_government_rank = 2
			}
			change_primary_culture = tunisian
			tunisia_area = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = TUN
			}
			if = {
				limit = {
					is_tribal = yes
				}
				change_government = despotic_monarchy #Desert tribes settling down.
			}
			add_prestige = 25
			set_capital = 341
			country_event = { id = ideagroups.1 } #Swap Ideas
		}
		ai_will_do = {
			factor = 1
		}
		ai_importance = 400
	}
	
	tripoli_nation = {
		major = yes
		potential = {
			normal_or_historical_nations = yes
			OR = {
				ai = no
				is_playing_custom_nation = no
			}
			NOT = { tag = MOR }
			NOT = { tag = TUN }
			NOT = { tag = TLC }
			NOT = { tag = ALG }
			NOT = { tag = TRP }
			NOT = { tag = PAP }
			NOT = { tag = HLR }
			OR = {
				primary_culture = tunisian
				primary_culture = berber
			}
			capital_scope = {
				OR = {
					area = tripolitania_area
					area = fezzan_area
				}
			}
			is_colonial_nation = no
			OR = {
				is_former_colonial_nation = no
				AND = {
					is_former_colonial_nation = yes
					ai = no
				}
			}
		}
		allow = {
			NOT = { exists = TRP }
			is_at_war = no
			is_subject = no
			is_nomad = no
			owns_core_province = 354 #Tripoli
			owns_core_province = 2589 #Thubaqt
			OR = {
				owns_core_province = 355 #Sirt
				owns_core_province = 353 #Djerba
			}
		}
		effect = {
			change_tag = TRP
			if = {
				limit = {
					is_part_of_hre = yes
					NOT = { has_country_modifier = european_union }
					is_elector = no
				}
				every_owned_province = {
					limit = {
						is_part_of_hre = yes
					}
					set_in_empire = no
				}
			}
			if = {
				limit = {
					NOT = { government_rank = 2 }
				}
				set_government_rank = 2
			}
			change_primary_culture = tunisian
			tripolitania_area = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = TRP
			}
			if = {
				limit = {
					is_tribal = yes #Desert tribes settling down.
				}
				change_government = despotic_monarchy
			}
			add_prestige = 25
			set_capital = 354 #Tripoli
			country_event = { id = ideagroups.1 } #Swap Ideas
		}
		ai_will_do = {
			factor = 1
		}
		#ai_importance = 400
	}
	
}
